<!DOCTYPE html>
<html>
<head>
    <title>部门用户列表</title>
    <#include "/common/import.ftl" >
    <script>
        var actsAry = "${acts!''}";//权限
        var utitle = '用户列表';
        var deptId = '${item.deptId!""}';
        if ($.trim(deptId).length != 0) {
            utitle = '[<font color="red">${item.deptCname!""}</font>]用户列表';
        }

        $(function () {
            $('#userList').datagrid({
                title: utitle,
                iconCls: 'icon-ok',
                url: '${ctx}/uct/user/user!data.action?deptId=' + deptId,
                nowrap: false,
                striped: true,
                collapsible: false,
                fitColumns: true,
                pagination: true,
                singleSelect: true,
                rownumbers: true,
                remoteSort: false,
                pageList: [10, 15, 50],
                idField: 'userId',
                columns: [[
                    {
                        field: 'userEname', title: '账号', width: 100, sortable: true,
                        sorter: function (a, b) {
                            return (a > b ? 1 : -1);
                        }
                    },
                    {
                        field: 'userCname', title: '姓名', width: 100, sortable: true,
                        sorter: function (a, b) {
                            return (a > b ? 1 : -1);
                        }
                    },
                    {
                        field: 'orgEname', title: '所属机构', width: 100, sortable: true,
                        sorter: function (a, b) {
                            return (a > b ? 1 : -1);
                        }
                    },
                    {
                        field: 'userType', title: '用户类型', width: 100, sortable: true,
                        sorter: function (a, b) {
                            return (a > b ? 1 : -1);
                        }
                        ,
                        formatter: function (value) {
                            if (value == '1') {
                                return '交易会员';
                            }
                            else if (value == '2') {
                                return '业务人员';
                            }
                            else {
                                return '';
                            }
                        }

                    },
                    {
                        field: 'userSex', title: '性别', width: 100,
                        formatter: function (value) {
                            if (value == '0') {
                                return '女';
                            } else {
                                return '男';
                            }
                        }
                    },
                    {field: 'phone', title: '电话', width: 100},
                    {
                        field: 'userStatus', title: '状态', width: 100,
                        formatter: function (value) {
                            if (value == '1') {
                                return '<font color=blue>启用</font>';
                            }
                            else {
                                return '<font color=red>停用</font>';
                            }
                        }
                    }
                ]]
            });

            $('#userList').datagrid('getPanel').panel({
                onExpand: function () {
                    $('#userActWin').panel('close');
                }
            });


            var p = $('#userList').datagrid('getPager');
            if (p) {
                $(p).pagination({
                    onBeforeRefresh: function () {
                    }
                });
            }

        });

        $(function () {
            $('#userActWin').panel({
                onClose: function () {
                    $('#userList').datagrid('getPanel').panel('expand');//
                },
                onExpand: function () {
                    $('#userList').datagrid('getPanel').panel('collapse');
                },
                onCollapse: function () {
                    $('#userList').datagrid('getPanel').panel('expand');
                }
            });

        });


        function reload() {
            $('#userList').datagrid('reload');
        }


        //新的查询功能
        function searchUserNew() {
            var queryParams = $('#userList').datagrid('options').queryParams;
            queryParams.userEname = $('#userEname').val();
            queryParams.userCname = $('#userCname').val();
            var options = $('#userList').datagrid('getPager').data("pagination").options;
            options.pageNumber = 1;
            options.total = 0;
            options.pageSize = 10;
            $('#userList').datagrid("reload");

        }

        function clearSearch() {
            $('#userEname').val('');
            $('#userCname').val('');
            $('#userId').val('');
        }


        function getSelected() {
            var selected = $('#userList').datagrid('getSelected');
            if (selected) {
                return selected;
            } else {
                $.messager.alert('提示', '请选择要操作的数据', 'info');
            }
        }

        function closeUserAdd() {
            $('#userAddWin').window('close');
        }

    </script>
</head>
<body>
<table class="datagrid-body">
    <tr>
        <td class="datagrid-header">
            用户账号
        </td>
        <td>
            <input id="userEname" name="userEname" value=""/>
        </td>
        <td class="datagrid-header">
            用户姓名
        </td>
        <td>
            <input id="userCname" name="userCname" value=""/>
        </td>

        <td>
            <a class="easyui-linkbutton" iconCls="icon-search"
               onclick="searchUserNew();">查询</a>
            <a class="easyui-linkbutton" iconCls="" onclick="clearSearch();">清空</a>
        </td>
    </tr>
</table>
<table id="userList"></table>


</body>
</html>